/**
 * @file       format_change.c
 * @author     ChenBlue
 * @email      chenblue952@qq.com
 * @version    V1.0
 * @date       2022-05-15
 * @brief      format change
 */
#include <stdio.h>
void rgb888to565(unsigned char* src, unsigned char* disc, int len)
{
	unsigned int red;
	unsigned int green;
	unsigned int blue;

	for (int i = 0; i < len; i++) {
		red = src[i * 3] & 0xf8;
		green = src[i * 3 + 1] & 0xfc;
		blue = src[i * 3 + 2] & 0xf8;

		disc[i * 2] = (red << 8 | green << 3 | blue >> 3) & 0xff;
        disc[i * 2 + 1] = (red << 8 | green << 3 | blue >> 3) >> 8;
	}
}
